/*  test function fgets and strtok
    如果读取的一行中有换行符的话，strtoc函数也能将换行符分离出来，
    可能会造成误操作
*/

#include<stdio.h>
#include<stdlib.h>

int main()
{
    FILE *file;
    if((file=fopen("./topo.txt","r"))==NULL)
    {
        printf("File could not be opened.\n");
        exit(0);
    }

    char A[50];

    fgets(A,1000,file);
    printf("%s\n",A);



    int cnt=1;
    char* B;
    B=strtok(A,"\t");
    //printf("%s\n",B);
    while(B!=NULL && strcmp(B,"\n")!=0)
    {
        printf("%d %s\n",cnt++,B);
        B=strtok(NULL,"\t");
    }
    /*
    int i=0;
    for(;i<50;i++)
    {
        //if(A[i]==0)
        //{
            printf("%d%c\n",i,A[i]);
            //break;
        //}
    }
    //*/
}
